// pages/category/category.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    selIndex: 0,
    categoryList:[],
    categoryImg:'',
    productList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    
    let categoryList=[
      {"categoryId":85,"parentId":0,"categoryName":"手机数码","pic":"https://img.mall4j.com/2019/04/4f148d81d60941b695cb77370a073653.jpg"},
      {"categoryId":87,"parentId":0,"categoryName":"美妆护肤","pic":"https://img.mall4j.com/2019/04/84f1a591a9ed46f68d46eee55c130b34.jpg"},
      {"categoryId":88,"parentId":0,"categoryName":"运动服饰","pic":"https://img.mall4j.com/2019/04/68f081f04c2644319d882a8828f4741c.jpg"},
      {"categoryId":95,"parentId":0,"categoryName":"美味零食","pic":"https://img.mall4j.com/2019/04/3483eafc86674a74bcf9da6100769a9a.jpg"}
    ]
    let categoryImg= categoryList[0].pic;
    let productList = [{"shopId":1,"shopName":"mall4j小店1","prodId":71,"prodName":"旗舰店官网 自拍神器 梵高定制","price":6998.0,"content":"<p><img src=\"http://img-test.gz-yami.com/2019/04/fa35b300102e45f3a57d7c5c775ebf6d.jpg\" alt=\"\" width=\"790\" height=\"853\" /></p>\n<p><img src=\"http://img-test.gz-yami.com/2019/04/f8fd168ddb8a437dbb5b742691bd1d02.jpg\" alt=\"\" width=\"800\" height=\"800\" /><img src=\"http://img-test.gz-yami.com/2019/04/db46108466264b48841b18437940e0b3.jpg\" alt=\"\" width=\"800\" height=\"800\" /></p>","oriPrice":10.0,"totalStocks":99,"brief":"梵高定制礼盒 全球限量发售 分期免息","pic":"https://img.mall4j.com/2019/04/667e4ce211b44c6da10891f42927fc11.jpg","imgs":"https://img.mall4j.com/2019/04/667e4ce211b44c6da10891f42927fc11.jpg,https://img.mall4j.com/2019/04/31c416e7020b4fe69d491bc09baaae90.jpg","categoryId":85,"skuList":null,"transport":null}]
    // 更新页面数据
    this.setData({
      categoryList:categoryList,
      categoryImg:categoryImg,
      productList:productList
    })
  },
  getProdList:function(id){
    let productList = [{"shopId":1,"shopName":"mall4j小店1","prodId":68,"prodName":"【Dole都乐】菲律宾都乐非转基因木瓜1只 单只约410g","price":26.0,"content":"<p style=\"text-align: justify;\"><img src=\"http://img-test.gz-yami.com/2019/04/e7536a53a83d450e8635ce1e9819faf6.jpg\" alt=\"\" width=\"790\" height=\"350\" /></p>","oriPrice":0.0,"totalStocks":0,"brief":"包邮 肉厚籽少 独具风味","pic":"https://img.mall4j.com/2019/04/0bfd73f43d764d20b2f0b92813abdc56.jpg","imgs":"https://img.mall4j.com/2019/04/0bfd73f43d764d20b2f0b92813abdc56.jpg,https://img.mall4j.com/2019/04/355020f27acd4b13a652cb830f03bedc.jpg","categoryId":95,"skuList":null,"transport":null},{"shopId":1,"shopName":"mall4j小店1","prodId":70,"prodName":"【Dole都乐】比利时Truval啤梨12只 进口水果新鲜梨 单果120g左右","price":38.0,"content":"<p><img src=\"http://img-test.gz-yami.com/2019/04/67ce2251e9b14ea08b87752ef7b30207.jpg\" alt=\"\" width=\"760\" height=\"488\" /></p>","oriPrice":0.0,"totalStocks":15,"brief":"好吃","pic":"https://img.mall4j.com/2019/04/de0edd2aaf2d4d3c8b6c3fdfde738805.jpg","imgs":"https://img.mall4j.com/2019/04/de0edd2aaf2d4d3c8b6c3fdfde738805.jpg,https://img.mall4j.com/2019/04/ee4530e364ca48869347e1e79915406c.jpg","categoryId":95,"skuList":null,"transport":null},{"shopId":1,"shopName":"mall4j小店1","prodId":73,"prodName":"阴阳师寮办秘制 月见和菓子 184克","price":22.0,"content":"<p><img src=\"http://img-test.gz-yami.com/2019/04/77f70d0c32c44294a2c80273262fa5fc.jpg\" alt=\"\" width=\"750\" height=\"750\" /></p>","oriPrice":0.0,"totalStocks":77,"brief":"三层夹心，Q弹有料","pic":"https://img.mall4j.com/2019/04/60c6300596504c10bd80d6365647b078.jpg","imgs":"https://img.mall4j.com/2019/04/60c6300596504c10bd80d6365647b078.jpg,https://img.mall4j.com/2019/04/11175723eae8431cabda164e0e197cb1.jpg","categoryId":95,"skuList":null,"transport":null},{"shopId":2,"shopName":null,"prodId":74,"prodName":"旺仔牛奶","price":100.0,"content":"<p>测试商品</p>","oriPrice":0.0,"totalStocks":0,"brief":"测试","pic":"https://img.mall4j.com/2019/05/b1a4bf7612554dbc8395f22e22d531c8.jpg","imgs":"https://img.mall4j.com/2019/05/b1a4bf7612554dbc8395f22e22d531c8.jpg","categoryId":95,"skuList":null,"transport":null},{"shopId":1,"shopName":"mall4j小店1","prodId":75,"prodName":"测试商品A","price":30.0,"content":"<p>测试</p>","oriPrice":30.0,"totalStocks":30,"brief":"","pic":"https://img.mall4j.com/2019/05/65525bbccee04ec5a094f38ce61d6b86.jpg","imgs":"https://img.mall4j.com/2019/05/65525bbccee04ec5a094f38ce61d6b86.jpg","categoryId":95,"skuList":null,"transport":null},{"shopId":1,"shopName":"mall4j小店1","prodId":76,"prodName":"测试商品B","price":40.0,"content":"<p>测试</p>","oriPrice":40.0,"totalStocks":40,"brief":"BBBB","pic":"https://img.mall4j.com/2019/05/150d6c4a46914dbfa82690098b2ec4e7.jpg","imgs":"https://img.mall4j.com/2019/05/150d6c4a46914dbfa82690098b2ec4e7.jpg","categoryId":95,"skuList":null,"transport":null},{"shopId":1,"shopName":"mall4j小店1","prodId":77,"prodName":"测试商品C","price":50.0,"content":"<p>CCCC</p>","oriPrice":60.0,"totalStocks":50,"brief":"CCC","pic":"https://img.mall4j.com/2019/05/1bdd097dbffd477799a7aca949377b20.jpg","imgs":"https://img.mall4j.com/2019/05/1bdd097dbffd477799a7aca949377b20.jpg","categoryId":95,"skuList":null,"transport":null}]
    if(id==87){
      productList = [{"shopId":1,"shopName":"mall4j小店1","prodId":71,"prodName":"旗舰店官网 自拍神器 梵高定制","price":6998.0,"content":"<p><img src=\"http://img-test.gz-yami.com/2019/04/fa35b300102e45f3a57d7c5c775ebf6d.jpg\" alt=\"\" width=\"790\" height=\"853\" /></p>\n<p><img src=\"http://img-test.gz-yami.com/2019/04/f8fd168ddb8a437dbb5b742691bd1d02.jpg\" alt=\"\" width=\"800\" height=\"800\" /><img src=\"http://img-test.gz-yami.com/2019/04/db46108466264b48841b18437940e0b3.jpg\" alt=\"\" width=\"800\" height=\"800\" /></p>","oriPrice":10.0,"totalStocks":99,"brief":"梵高定制礼盒 全球限量发售 分期免息","pic":"https://img.mall4j.com/2019/04/667e4ce211b44c6da10891f42927fc11.jpg","imgs":"https://img.mall4j.com/2019/04/667e4ce211b44c6da10891f42927fc11.jpg,https://img.mall4j.com/2019/04/31c416e7020b4fe69d491bc09baaae90.jpg","categoryId":85,"skuList":null,"transport":null}]
    }

    this.setData({
      productList:productList
    })
  },
  // 点击左边类型列表时触发
  onMenuTab: function (e) {
    var id = e.currentTarget.dataset.id;
    var index = e.currentTarget.dataset.index;
    this.getProdList(this.data.categoryList[index].categoryId);
    this.setData({
      categoryImg: this.data.categoryList[index].pic,
      selIndex: index
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})